<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html lang="zh-CN">
    <head> 
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <%@ include file="/WEB-INF/views/include/head.jsp"%>
    <script src="${ctxStatic}/js/jquery-1.9.1.min.js"></script>
    <script src="${ctxStatic}/js/DateTimePicker.js"></script>
    <script src="${ctxStatic}/js/layer.js"></script>
    <script src="${ctxStatic}/js/style.js"></script>
    <script src="${ctxStatic}/dateCalendar/WdatePicker.js"></script>
    <link rel="stylesheet" href="${ctxStatic}/css/common_erp.css">
    <link rel="stylesheet" href="${ctxStatic}/css/list.css">
    <script>
    $(document).ready(function() {
    	$("#materialTypeCd,#businessType").select2();
	});
	// 检索方法
	function searchListForm() {
		var params = $("#searchForm").serialize();
		$("#activity_pane").showLoading();
		$.post("${ctx}/stock/warning/searchList",params,function(result) {
					var listHtml = result["inventory"];
					var pageHtml = result["page"];
					$("#listHtml").html(listHtml);
					$("#paging").html(pageHtml);
					$("#activity_pane").hideLoading();
				}, 'json');
	}
	 
	$(function(){
		    searchListForm();
		
            $(".tabBox ul li").each(function(){
                var index=$(this).index();

                $(".tabBox ul li").eq(0).addClass("active");

                $(this).click(function(){                  
                    $(this).addClass("active").siblings().removeClass("active");
					
                    $("#materialStatus").val($(this).val());
                    searchListForm();
                    
					var tableW = $(".tabBoxSm > .tabSm").eq(index).find('.tableHead').width();
					var tabodyH = $(".tabBoxSm > .tabSm").eq(index).find('.tableBody').height();
					var tableScrollH = $(".tabBoxSm > .tabSm").eq(index).find('.tableScroll').height();
					if(tabodyH>tableScrollH){
						$(".tabBoxSm > .tabSm").eq(index).find('.tableScroll').css('width',tableW + 18 + 'px')
					}else{
						$(".tabBoxSm > .tabSm").eq(index).find('.tableScroll').css('width','inherit')
					}
                })
            })
        })


	//重置
	function clean() {
		$("select").val("");
		$(".searchArea").find("input").val("");
		searchListForm();
	} 
	// 迁移物料画面
	function toShowImage(index) {
		var materialStatus = $("#listHtml tr").eq(index).find(".materialStatus").val();
		var materialCode = $("#listHtml tr").eq(index).find(".materialCode").val();
		var materialNameCn = $("#listHtml tr").eq(index).find(".materialNameCn").val();
		var materialColor = $("#listHtml tr").eq(index).find(".materialColor").val();
		var materialComposition = $("#listHtml tr").eq(index).find(".materialComposition").val();
		var materialSpec = $("#listHtml tr").eq(index).find(".materialSpec").val();
		var materialQuantity = $("#listHtml tr").eq(index).find(".materialQuantity").val();
		var uploadFile = $("#listHtml tr").eq(index).find(".uploadFile").val();
		var materialId = $("#listHtml tr").eq(index).find(".materialId").val();
		var alertId = $("#listHtml tr").eq(index).find(".alertId").val();
		var ognizationId = $("#listHtml tr").eq(index).find(".ognizationId").val();
		var purchaseReserveQuantity = $("#listHtml tr").eq(index).find(".purchaseReserveQuantity").val();
		var purchaseUnitPrice = $("#listHtml tr").eq(index).find(".purchaseUnitPrice").val();
		var purchaseTaxRebate = $("#listHtml tr").eq(index).find(".purchaseTaxRebate").val();
		popup('900px','584px','${ctx}/stock/warning/toShowMessage?materialCode='+materialCode+
				'&materialNameCn='+materialNameCn+'&materialColor='+materialColor+'&materialComposition='+materialComposition+
				'&materialSpec='+materialSpec+'&materialQuantity='+materialQuantity+"&uploadFile="+uploadFile+"&materialId="+materialId+
				'&ognizationId='+ognizationId+'&alertId='+alertId+'&materialStatus='+materialStatus);
	}
	
	function deleteThis(alertId){
		if(confirm("确定删除吗？")){
			var params = {"alertId":alertId};
			$.post("${ctx}/stock/warning/delete",params,function(result) {
				tipParent(result.message);
				searchListForm();
			}, 'json');
		}
	}
    </script>
</head>
<body>
<form id="searchForm" method="post">
<div class="listArea" id="activity_pane">
	<div class="listBg">
        <div class="searchArea clearfix">
            <div class="searchLeft clearfix">
                <!-- 原辅料名称 -->
                <div class="searchInp clearfix">
                    <p><spring:message code="orderMaterielDetail_materialNameCn" /></p>
                    <input class="w-styleNub" id="materialNameCn" name="materialNameCn">
                </div>
                <!-- 物料类别 -->
                <div class="searchInp clearfix">
                    <p><spring:message code="myWarehouse_type" /></p>
                    <select style="width: 170px" id="materialTypeCd" name="materialTypeCd" >
							<option value=""><spring:message
									code="style_pleaseSelect" /></option>
							<c:forEach items="${categoryList}" var="item">
								<option value="${item.itemCode}-${item.itemValue}">${item.itemName}</option>
							</c:forEach>
						</select>
                </div>
                <!-- 业务类别 -->
                <div class="searchInp clearfix">
                    <p><spring:message code="finance_businessClass" /></p>
                     <select style="width: 170px" id="businessType" name="businessType" >
							<option value=""><spring:message
									code="style_pleaseSelect" /></option>
							<c:forEach items="${businessType}" var="item">
								<option value="${item.itemCode}-${item.itemValue}">${item.itemName}</option>
							</c:forEach>
						</select>
                </div>
               
                <!-- 日期 -->
                <div class="searchInp clearfix">
                    <p style="width:40px"><spring:message code="finance_date" /></p>
                    <div class="timeBox">
                        <input type="text" class="laydate-icon" onclick="WdatePicker({el:this,dateFmt:'yyyy-MM-dd',onpicked:null})"	id="dateFrom" name="dateFrom" style="width: 120px">
						<p class="list">~</p>
						<input type="text" class="laydate-icon" id="dateTo" name="dateTo" style="width: 120px" onclick="WdatePicker({el:this,dateFmt:'yyyy-MM-dd',onpicked:null})">
                    </div>        
                </div>
            </div>
            <div class="searchRight clearfix">
                <button type="button" onclick="searchListForm();"><spring:message code="commom_check"/></button>
                <button type="button" onclick = "clean()"><spring:message code="common_reset" /></button>
            </div>
        </div>
    
    </div>
    <input type="hidden" id="materialStatus" name="materialStatus" value="0"/>
    <div class="tabBox">
        <ul class="clearfix">
            <!-- 全部 -->
            <li class="active" value="0"><spring:message code="bigConsumption_status_all" /></li>
            <!-- 待采购 -->
            <li value="1"><spring:message code="waitingPurchase" /></li>
            <!-- 已采购 -->
            <li value="2"><spring:message code="alreadyPurchase" /></li>
            <!-- 已入库 -->
            <li value="3"><spring:message code="alreadyInbound" /></li> 
        </ul>
	</div>
	<div class="addRow none">
				<table cellpadding="0" class="tableBody">
					<tbody>
						<tr>
							<td style="width: 50px"><img
								src="${ctxStatic}/images/del_icon.png" class="delBtn"
								onclick='removeVender(this)'></td>
							<td class="selectVenderId" style="width: 155px"><select
								name="venderId" style="width: 155px"
								onchange="selectChange(this);">
									<c:forEach items="${venderList}" var="vender">
										<option value="${vender.venderId}">
											${vender.venderNameCn}</option>
									</c:forEach>
							</select></td>
							<td style="width: 110px" class="sub-PurchaseReserveQuantity"><fmt:formatNumber value="0" pattern="##0.00##" /></td>
							<td style="width: 110px" class="sub-PurchaseUnitPrice"><fmt:formatNumber value="0" pattern="##0.00##" /></td>
							<td style="width: 110px" class="sub-PurchaseTaxRebate"><fmt:formatNumber value="0" pattern="##0.00#" /></td>
							<td style="width: 110px" class="PurchaseUnitCost"><fmt:formatNumber value="0" pattern="##0.00###" /></td>
							<td style="width: 110px" class="PurchasePrice"><fmt:formatNumber value="0" pattern="##0.00##" /></td>
							<input type="hidden" class="subHiddenVenderId"
								name="venderIdtemp"
								value="${venderList[0].venderId }" />
							<input type="hidden" class="subHiddenPurchaseReserveQuantity"
								name="purchaseReserveQuantitytemp" value="0" />
							<input type="hidden" class="subHiddenPurchaseUnitPrice"
								name="purchaseUnitPricetemp" value="0" />
							<input type="hidden" class="subHiddenPurchaseTaxRebate"
								name="purchaseTaxRebatetemp" value="0" />
						</tr>
					</tbody>
				</table>
			</td>
			</div>
    <div class="listBg tabPadding overflowX">
        <div class="tableArea tabBoxSm">
            <div class="tableScrollSm" style = "height:650px;overflow: auto;width: 1135px;">
                <table cellpadding="0" class="tableHead" >
                    <thead>
                    <tr>
                        <th><p style="width:50px"><spring:message code="bigConsumption_head_no" /></p></th>
                        <th><p style="width:95px"><spring:message code="myWarehouse_pic" /></p></th>
                        <th><p style="width:110px"><spring:message code="quotation_create_materailNameNO" /></p></th>
                        <th><p style="width:35px"><spring:message code="quotation_create_materailSpec" /></p></th>
                        <th><p style="width:45px"><spring:message code="quotation_create_materailSpecUnit" /></p></th>
                        <th><p style="width:45px"><spring:message code="contract_size_color" /></p></th>
                        <th><p style="width:75px"><spring:message code="material_composition" /></p></th>
                        <th><p style="width:75px"><spring:message code="material_showMateial_materialType" /></p></th>
                        <th><p style="width:75px"><spring:message code="material_businessType" /></p></th>
                        <th><p style="width:75px"><spring:message code="orderMaterielDetail_stockQuantity" /></p></th>
                        <th><p style="width:75px"><spring:message code="inventoryWarning_materialAlertQuantity" /></p></th>
                        <th><p style="width:70px"><spring:message code="warningDate" /></p></th>
                        <th><p style="width:55px"><spring:message code="supplier_txt_supplier" /></p></th>
                        <th><p style="width:70px"><spring:message code="orderMateriel_show_material_purchaseReserveQuantity" /></p></th>
                        <th><p style="width:75px"><spring:message code="purchaseDate" /></p></th>
                        <th><p style="width:75px">操作</p></th>
                    </tr>
                    </thead>
                </table>
                <table cellpadding="0" class="tableBody">
					<tbody id="listHtml">
					</tbody>
                </table>
            </div>
    </div>
    </div>
    <div id="paging"></div>
    </div>
</form>
</body>
</html>